package com.itheima.web;


import com.itheima.dto.SetmealDto;
import com.itheima.pojo.Setmeal;
import com.itheima.result.R;
import com.itheima.service.SetmealDtoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: 斌
 * @DateTime: 2023年02月07日  00:07:43
 * @Description: com.itheima.web
 * @Version: 1.0
 */
@RestController
@RequestMapping("/setmeal")
public class SetmealController {
    @Autowired
    private SetmealDtoService setmealDtoService;
    @GetMapping("/page")
    public R SetmealPage(Integer page,Integer pageSize,String name){
       return setmealDtoService.SetmealPage(page,pageSize,name);
    }
    @PostMapping()
    public R saveSetMeal(@RequestBody SetmealDto setmealDto){
        return setmealDtoService.saveSetMeal(setmealDto);
    }
    @GetMapping("/{id}")
    public R querySetmeal(@PathVariable Long id){
        return setmealDtoService.querySetmeal(id);
    }
    @PutMapping()
    public R updateSetmeal(@RequestBody SetmealDto setmealDto){
        return setmealDtoService.updateSetmeal(setmealDto);
    }
    @DeleteMapping()
    public R deleteSetmeal(@RequestParam("ids") List<Long> ids){
        return setmealDtoService.deleteSetmeal(ids);
    }

    @PostMapping("/status/{status}")
    public R updateSetmealStatus(@PathVariable Integer status,@RequestParam("ids") List<Long> ids){
        return setmealDtoService.updateSetmealStatus(status,ids);
    }
    @GetMapping("/list")
    public R setmealList(SetmealDto setmealDto){
       return setmealDtoService.setmealList(setmealDto);
    }
    @GetMapping("/dish/{id}")
    public R querySetmealDish(@PathVariable Long id){
        return setmealDtoService.querySetmealDish(id);
    }

}
